<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<title>湖南省自来水公司营销管理信息系统 - 员工登陆</title>

	<link rel="stylesheet" href="./css/reset.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="./css/text.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="./css/form.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="./css/buttons.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="./css/login.css" type="text/css" media="screen" title="no title" />
	<script src="/js/vue3.js" ></script>
	<script src="/js/axios.js"></script>
</head>

<body>
<div id="login_background">
<div id="login">
	<h1>员工登陆</h1>
	<div id="login_panel">
		<form action="javascript:;" method="post" accept-charset="utf-8">
			<div class="login_fields">
				<div class="field">
					<label for="email">员工工号：</label>
					<input type="text" name="email" v-model="emp.email" id="email" tabindex="1" placeholder="请输入您的员工编号" />
				</div>
				<div class="field">
					<label for="password">登陆密码： </label>
					<input type="password" name="123456" v-model="emp.password" id="password" tabindex="2" placeholder="请输入您的密码" />
				</div>
			</div> <!-- .login_fields -->

			<div class="login_actions">
				<button type="button"  @click="login" class="btn btn-orange" tabindex="3">登陆</button>
			</div>
		</form>
	</div> <!-- #login_panel -->
</div>
<!-- #login -->
</div>
</body>
<script>
	var app=Vue.createApp({
		data(){
			return {
				emp:{
					email:"admin",
					password:"123456"
				}
			}
		},
		methods:{
			login(){

				axios.post("/autoWater/login",this.emp).then(response=>{
					if (response.data.data){
						//存入到session中
						sessionStorage.setItem("user", JSON.stringify(response.data.data))
						window.location = "/workspace.html";
					}else {
						alert(response.data.errorMessage)
					}
				})
			}
		}
	}).mount("#login_background")
</script>
</html>
